1. Field of the Invention
The present invention relates to a video compression device compressing video images, and more particularly to a video compression device and a video compression method allowing video data to be transmitted at an optimum frame rate in accordance with the input frame rate of original images, such as MPEG1-compressed video, and a user-specified compression level.
2. Description of the Related Art
Digitized images recorded on recording media, such as CD-ROM discs or hard disks, are usually compressed because they take up a huge amount of space. There are many compression methods. In many cases, the DCT-based coding method is used. It takes advantage of the characteristics that the spatial frequencies of an image concentrate on low frequencies. This coding method is adopted as the international standard coding methods such as JPEG (Joint Photographic Expert Group) or MPEG (Moving Pictures Expert Group) 1 and 2.
These storage types of video compression methods, such as MPEG1, use a predetermined number of frames per unit time. Therefore, when the frame rate of the input image is lower than that of MPEG1, the same frame must be inserted more than once. This generates redundant frames, thus decreasing compression efficiency. On the other hand, the international standard MPEG1 coding method cannot increase the compression rate by reducing the frame rate.
The xe2x80x9cvideo signal coding method and video signal coding unitxe2x80x9d, disclosed in Japanese Patent Laid-Open Application No. Hei 10-42295, is designed to reduce the amount of redundant frames. To reduce the coding amount of frames, the unit and method disclosed in this publication generate a code indicating that a frame generated during inter-frame compression is a copy of some other frame, as shown in FIG. 9.
That is, to reduce the virtual frame rate while satisfy the frame rate defined by MPEG, the unit described in the above publication has a copy stream generator 49 generating a copy-word bit stream (copy system) indicating that a picture is the same as another already-copied picture. A system controller 45 does not perform movement compensation for B pictures or P pictures to be deleted; instead, the system controller 45 supplies a code-word bit stream (copy stream) 49a, output from the copy stream generator 49, to a buffer 37 via an output data switching switch 46 which constitutes a code multiplexer. Periodically inserting the code-word bit stream created by simply copying the preceding or following frame makes a frame rate lower than the normal frame rate.
On the other hand; the xe2x80x9cvideo image coding unitxe2x80x9d, disclosed in Japanese Patent Publication (unexamined) No. A-9-130787, controls a switch 101, as instructed by a control signal from the coding control circuit for frame processing, as shown in FIG. 10. This unit selects frames to be skipped according to the actual amount of coding to adjust the frame rate.
That is, to implement a coding frame rate in accordance with the picture quality and to cause a little delay, the unit disclosed in this publication comprises a coding unit 117 which codes input video signals, an output buffer 115 which receives data coded by the coding unit 117 and outputs the coded data at a predetermined rate, and a coding control circuit 116 which selects frames to be coded. The coding control circuit 116 calculates the target amount of coding for each frame based on the externally-set coding bit rate, coding frame rate, and allowable delay time. It them compares the calculated value with the actual value, controls a quantization circuit 106 and the switch 101, and adjusts the quantization parameters and the number of frames to be skipped.
However, on the xe2x80x9cvideo signal coding method and video signal coding unitxe2x80x9d disclosed in Japanese Patent Publication (unexamined) No. A-10-42295, the frequency at which code indicating that a frame is a copy of some other frame is generated does not always match the input frame rate or the user-desired virtual output frame rate. This means that processing all input image data decreases efficiency.
On the xe2x80x9cvideo image coding unitxe2x80x9d disclosed in Japanese Patent Publication (unexamined) A-9-130787, the frame rate depends on the amount of coding, preventing some images from moving smoothly.
The present invention seeks to solve the problems associated with prior arts described in the above publications. It is an object of the present invention to provide a video compression device and a video compression method which provide efficiently-compressed and smoothly-moving video.
When the frame rate of the input image differs from a desired frame rate on a compressed video storage device, the present invention enables the user to generate the optimum frame configuration so that video may be compressed efficiently and to delete or insert frames according to the configuration while using as much input frames as possible.
The present invention provides a video compression device compressing video signals, comprising:
a frame receiving unit receiving the video signals, one frame at a time;
a frame checking unit checking a type of the frame to be processed and passing control to an appropriate unit;
a motion search unit searching a small block for a motion of an image;
a frequency conversion unit converting the image of the small block to a spatial frequency;
a quantization unit performing quantization for the image signals frequency-converted by the frequency conversion unit;
a reverse quantization unit performing reverse quantization for the signals output from the quantization unit;
a reverse frequency conversion unit performing reverse frequency conversion for the signals output from the reverse quantization unit;
a motion compensation unit compensating a motion of the image of the small block and generating an original image; and
a variable-length coding unit performing variable-length coding for the signals output from the quantization unit and outputting the signals to a compressed code output unit.
In addition, the present invention provides a video compression method of compressing video signals, the method being processed by a frame receiving unit receiving the video signals, one frame at a time; a frame checking unit checking a type of the frame to be processed and passing control to an appropriate unit; a motion search unit searching a small block for a motion of an image; a frequency conversion unit converting the image of the small block to a spatial frequency; a quantization unit performing quantization for the image signals frequency-converted by the frequency conversion unit; a reverse quantization unit performing reverse quantization for the signals output from the quantization unit; a reverse frequency conversion unit performing reverse frequency conversion for the signals output from the reverse quantization unit; a motion compensation unit compensating a motion of the image of the small block and generating an original image; and a variable-length coding unit performing variable-length coding for the signals output from the quantization unit and outputting the signals to a compressed code output unit, the method comprising the steps of:
identifying the type of the frame by the frame checking unit that the frame is an I frame, P frame, or B frame;
passing control to the frequency conversion unit if the frame is the I frame;
passing control to the motion search unit if the frame is the P frame; and
passing control directly to the compressed code output unit if the frame is the B frame.
The present invention also provides a video compression method according to the above-described method, further comprising the steps of:
getting a frame rate of the input video image;
getting a user-specified compression level;
if the input frame rate is smaller than a predetermined maximum output frame rate, changing the predetermined maximum output frame rate to the input frame rate;
calculating an effective frame rate according to:
formula: (Levelxe2x88x921)xc3x97(Maxxe2x88x92Min)/(Sizexe2x88x921)+Min;
where, Level: User-specified compression level (an integer equal to or larger than 1);
Max: Maximum effective compression frame rate;
Min: Minimum effective compression frame rate; and
Size: Maximum compression level;
selecting an output frame rate with a least common multiple with the effective frame rate from the output frame rates 23.976, 24, 25, 29.97, and 30; and
outputting the image data to the compressed code output unit by calculating a frame number of the image to be compressed (beginning with 0) using the input frame rate and the output frame rate according to:
formula: Nxc3x97R1/R2;
where, N: number of compressed frames compressed so far (integer value 0 or larger);
R1: Input frame rate; and
R2: output frame rate.
The present invention also provides a video compression method according to the above-described method, further comprising the steps of:
finding a number of compressed frames output to the compressed code output unit;
getting the effective frame rate;
getting the output frame rate;
checking if a count (initial of 0) of the B frames is larger than 0;
if the count is not larger than 0,
calculating the number of the B frames to be used next according to:
formula: (Kxc3x97R1/R2)xe2x88x92Nxe2x88x921;
where, N: number of frames compressed so far;
K: number of calculations (beginning with 1);
R1: output frame rate; and
R2: effective frame rate;
storing the number of the B frames;
checking if the number of compressed frames is a multiple of the output frame rate;
if so:
making the frame to be compressed an I frame;
finding the number of code bytes according to:
formula: (F1xc3x97(V2/V1)xc3x97xcex11)/8+1
where F1: average number of code bits per frame of a reference image;
V1: reference image size;
V2: current image size; and
xcex11: compensation value of I frame; and
allocating code memory for the code bytes; and
if not:
making the frame to be compressed a P frame;
finding the number of code bytes according to:
(F1xc3x97(V2/V1)xc3x97xcex12)/8+1xe2x80x83xe2x80x83formula
where, F1: average number of code bits per frame of the reference image;
V1: reference image size;
V2: current image size; and
xcex12: Compensation value of P frame; and
allocating the code memory for the code bytes; and
if the count is larger than 0, making the type of the frame to be compressed a B frame;
finding the number of code bytes according to:
formula: ((MBxe2x88x9234)/33xc3x97ESC+HEAD)/8+1
where MB: Number of macro blocks (16xc3x9716 blocks) of a screen;
ESC: Number of MBESC code bits (11 bits); and
HEAD: Maximum number of non-MBESC code bits (142 bits); and
allocating the code memory for the code bytes.
The present invention also provides a computer program product stored on a storage medium for controlling a video compressing device comprising a frame receiving unit receiving the video signals, one frame at a time; a frame checking unit checking a type of the frame to be processed and passing control to an appropriate unit; a motion search unit searching a small block for a motion of an image; a frequency conversion unit converting the image of the small block to a spatial frequency; a quantization unit performing quantization for the image signals frequency-converted by the frequency conversion unit; a reverse quantization unit performing reverse quantization for the signals output from the quantization unit; a reverse frequency conversion unit performing reverse frequency conversion for the signals output from the reverse quantization unit; a motion compensation unit compensating a motion of the image of the small block and generating an original image; and a variable-length coding unit performing variable-length coding for the signals output from the quantization unit and outputting the signals to a compressed code output unit, wherein the program causes the video compression device to:
identify the type of the frame by the frame checking unit that the frame is an I frame, P frame, or B frame;
pass control to the frequency conversion unit if the frame is the I frame;
pass control to the motion search unit if the frame is the P frame; and
pass control directly to the compressed code output unit if the frame is the B frame.
More specifically, the frame receiving unit 11 shown in FIG. 2 deletes or inserts a received image, one frame at a time, so that the optimum output frame rate calculated from the input frame rate of the original image and the user-specified compression level may be obtained. The frame checking unit 12 checks the current frame type. An I frame and a P frame are compressed as usual, while a B frame is not actually compressed. For the B frame, a code indicating that the frame is the same as the reference frame is inserted.